<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
   <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

	<table class="table">
		<tr>
			<th>课程</th><th>成绩</th>
		</tr>
		<c:forEach items="${student.grades}" var="c">
			<tr>
				<td>${c.course.courseName}</td>
				<td>
				   	<input type="text" onchange = "changecj(this.value, ${c.id})" name="grade" class="form-control" placeholder="成绩" value="${c.grade }">
				</td>
			</tr>
		</c:forEach>
	</table>

	
<script type="text/javascript">
function changecj(grade,id){
	var k = checkRegexp(grade,/^[0-9]*$/,"请输入正确成绩！")
	if(k==false){
		return false;
	}else if(grade<0||grade>100){
		alert("请输入百分之成绩");
		return false;
	}else{
		$(function(){
			$.post("../grade/updata1?grade="+grade+"&id="+id);
		});
		return true;
	}
}

function checkRegexp(o,regexp,n){
	if(!(regexp.test(o))){
		alert(n);
		return false;
	}else{
		return true;
	}
}
</script>